//
//  ViewController.swift
//  AQAlgorithm
//
//  Created by zhangjikuan on 2020/6/16.
//  Copyright © 2020 hsgd. All rights reserved.
//

import UIKit

/// 访问控制模型基于模块和源文件两个概念

/// 模块指的的独立的代码单元，框架活应用程序作为一个独立的模块来构建和发布。
// 在swift中，一个模块可以使用import关键字导入另一个模块。


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var arr = [19,2,3,4,6,33,6,7,9,12]
        
        let sort = AQShellSort()
        
        print("排序钱的数组\(arr)")

        sort.sort(&arr)
        
        print("排序后的数组\(arr)")
        
        
        
        let tuple = someFunction()
        
        print(tuple.0)
        
        print(tuple.1)
        
        print(tuple.self)
        
        let aqcl = AQClosure()
        
        aqcl.test()
        
        
        
        
    }

    // 此函数返回的是一个元组
    func someFunction() -> (String, [String]) {
        return ("Yi",["One","Tow","Three"])
    }
    
    
    
    
}



public protocol Module {
    static func load() -> Module
}

class ModlueManager {
    static let shared = ModlueManager()
    var allModules: [Module] = []

    private init() {
        
    }
    
    @discardableResult
    func loadModule(_ moduleName: String) -> Module {
        let type = NSClassFromString(moduleName) as! Module.Type
        let module = type.load()
        self.allModules.append(module)
        return module
    }
    
    class func loadModules(fromPlist fileName: String) {
        let plistPath:String = Bundle.main.path(forResource: fileName, ofType: nil) ?? ""
        let moduleNames = NSArray(contentsOfFile: plistPath) as! [String]
        for (_, modleName) in (moduleNames.enumerated()) {
            self.shared.loadModule(modleName)
        }
        
        
    }
}
//
//class HomeModule: Module {
//    static func load() -> Module {
//        return HomeModule()
//    }
//
//    private init() {
//        NotificationCenter.
//        NotificationCenter.observeNotificationOnce(NSNotification.Name.UIApplicationDidFinishLaunching) { (notification) in
//                self.window = UIWindow(frame: UIScreen.main.bounds)
//                self.window?.backgroundColor = UIColor.white
//                let homeViewController = ViewController()
//                let navigationController = UINavigationController(rootViewController: homeViewController)
//                self.window?.rootViewController = navigationController
//                self.window?.makeKeyAndVisible()
//            }
//    }
//}
//
//
